<template>
  <div>
    <div
      class="title"
      :style="'height: '+height+'px;'"
    >
      <div
        class="row"
        :style="back?'justify-content:space-between':'justify-content:center'"
      >
        <img
          v-if="back"
          src="../images/arrow_left.png"
          mode="aspectFit"
          @click="comeBack"
        >
        <div class="text">{{title}}</div>
        <div
          v-if="back"
          class="blank"
        ></div>
      </div>
    </div>
    <div :style="'height: '+height+'px;'"></div>
  </div>
</template>
 
 <script>
export default {
  data() {
    return {
    };
  },
  props: ["title", "back"],
  methods: {
    comeBack() {
      if (getCurrentPages().length > 1) {
        wx.navigateBack({
          delta: 1,
        });
      } else {
        wx.switchTab({
          url: "/pages/index/main"
        });
      }
    }
  },
  computed: {
    height() {
      return this.globalData.height ? this.globalData.height : 70;
    }
  }
};
</script>
 
 <style lang='scss' scoped>
div,
p {
  box-sizing: content-box;
}
.title {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  position: fixed;
  top: 0;
  left: 0;
  width: 750rpx;
  background: #fff;
  z-index: 20;
  color: #000;
  .row {
    display: flex;
    justify-content: space-between;
    width: 700rpx;
    height: 76rpx;
    margin-bottom: 10rpx;
    .text {
      font-size: 36rpx;
      font-weight: 900;
      height: 48rpx;
      line-height: 48rpx;
    }
    img {
      width: 36rpx;
      height: 36rpx;
      padding: 20rpx;
    }
    .blank {
      width: 36rpx;
      height: 36rpx;
      padding: 20rpx;
    }
  }
}
</style>

 